package com.atshiyou.web;

import com.atshiyou.bean.Student;
import com.atshiyou.service.impl.StudentDaoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(value = "/getAllstudents")
public class StudentServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1、接收参数
        ///2、调取service方法
        StudentDaoServiceImpl studentDaoService = new StudentDaoServiceImpl();
        List<Student> all = studentDaoService.findAll();
        req.setAttribute("student",all);
        //3、跳转页面
        req.getRequestDispatcher("./show.jsp").forward(req,resp);
    }
}
